<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>使用bootstrap绘制form表单</title>
<!-- Bootstrap core CSS -->
<link
	href="${pageContext.servletContext.contextPath}/static/plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.servletContext.contextPath}/static/plugins/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css"
	rel="stylesheet">
<!-- bootstrap-datepicker-1.9.0-dist -->
<link
	href="${pageContext.servletContext.contextPath}/static/plugins/bootstrap-datepicker-1.9.0-dist/css/bootstrap-datepicker.min.css"
	rel="stylesheet">

<!-- Bootstrap core JavaScript-->
<!-- Placed at the end of the document so the pages load faster -->
<!--import jquery before bootstrap javascript-->
<script
	src="${pageContext.servletContext.contextPath}/static/plugins/jquery-1.12.4/jquery-1.12.4.min.js"></script>
<script
	src="${pageContext.servletContext.contextPath}/static/plugins/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!-- bootstrap-datepicker-1.9.0-dist -->
<script
	src="${pageContext.servletContext.contextPath}/static/plugins/bootstrap-datepicker-1.9.0-dist/js/bootstrap-datepicker.min.js"></script>

<script
	src="${pageContext.servletContext.contextPath}/static/plugins/bootstrap-datepicker-1.9.0-dist/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<!-- My97DatePicker -->
<script
	src="${pageContext.servletContext.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"></script>



<script type="text/javascript">
	// 给日期输入框添加事件处理
	$(function() {
	// dom ready 直接执行的代码块
		$("#txtCreateDate1").datepicker({
			 format: "yyyy-mm-dd",
			 language: "fr",
			 todayBtn: true
		});
		
		// 执行ajax查询操作
		doAjaxQuery();
	});
	
	// ajax进行查询，填充表单标签值
	
	function doAjaxQuery(){
		// 使用ajax进行查询
		$.ajax({
				// 请求类型
			   type: "POST",
				// 请求的url，和form的action属性值一样
			   url: "${pageContext.servletContext.contextPath}/UserInfoAjaxPreModifyControl",
				// 发送的表单数据，按照如下格式提供即可："name=John&location=Boston"
			   data:  "user_Id="+$("#user_id").val(), // 序列化表单参数，获取一个序列化的字符串，用于ajax请求，必须在form中才可以使用
			   // response响应的数据类型，默认是文本类型，可以指定为 xml、html、json等类型
			   dataType:"json",
			   // 回调函数
			   success: function(data){			     
			     // 进行dom操作，局部修改浏览器的显示数据，进行局部刷新数据
				 if(data != null){
					 // 使用dom操作进行表单数据填充
					 // data是一个实体类的json对象
					 $("#txtUserName").val(data.user_Name);
					 $("#txtUserPsw,#txtUserPsw2").val(data.user_Psw);
					 $("#txtCreateDate").val(data.user_Createtime);
					 //$("#txtUserName").val(data.user_Name);					 
				 }
			   }

			});
	}
	
	
	
	
</script>

<style>
#maindiv {
	width: 80%;
	padding-top: 10px;
}
</style>
</head>
<body>
	<div id="maindiv">
		<form id="modifyForm" class="form-horizontal"
			action="${pageContext.servletContext.contextPath}/UserInfoSavingControl"
			method="post">
			<!-- 添加隐藏表单域是为了修改使用；将当前修改的记录的主键一并通过form表单传到服务器 -->
			<input type="hidden" id="user_id" name="user_Id" value="${userId }">
			
			<div class="form-group">
				<label class="col-sm-2 control-label">用户名</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="txtUserName"
						name="user_Name" placeholder="请输入用户名">
				</div>

				<label class="col-sm-2 control-label">密码</label>
				<div class="col-sm-4">
					<input type="password" class="form-control" id="txtUserPsw"
						name="user_Psw"  placeholder="请输入密码">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">确认密码</label>
				<div class="col-sm-4">
					<input type="password" class="form-control" id="txtUserPsw2" 					 
						placeholder="请输入确认密码">
				</div>

				<label class="col-sm-2 control-label">创建日期</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="txtCreateDate" name="user_Createtime" onClick="WdatePicker()"
						placeholder="请选择创建日期">
				</div>
			</div>			
		</form>
	</div>
</body>
</html>